{% extends theme("user/profile_layout.html") %}
{% from theme('macros.html') import render_pagination, topic_pages %}

{% block breadcrumb %}
<ul class="breadcrumb flaskbb-breadcrumb">
    <li><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
    <li><a href="{{ user.url }}">{{ user.username }}</a></li>
    <li class="active">{% trans %}Topics{% endtrans %}</li>
</ul>
{% endblock %}

{% block profile_navigation %}
<ul class="nav profile-sidenav" id="profile-tabs" role="tablist">
    <li>
        <a href="{{ user.url }}">
            <span class="fa fa-home"></span> {% trans %}Overview{% endtrans %}
        </a>
    </li>
    {#
    <li>
        <a href="{{ user.url }}">
            <span class="fa fa-line-chart"></span> {% trans %}Statistics{% endtrans %}
        </a>
    </li>
    #}
    <li class="active">
        <a href="{{ url_for('user.view_all_topics', username=user.username) }}">
            <span class="fa fa-comments"></span> {% trans %}Topics{% endtrans %}
        </a>
    </li>

    <li>
        <a href="{{ url_for('user.view_all_posts', username=user.username) }}">
            <span class="fa fa-comment"></span> {% trans %}Posts{% endtrans %}
        </a>
    </li>
</ul>
{% endblock %}

{% block profile_content %}
<!-- middle column -->
<div class="col-md-9 col-sm-9 col-xs-12 profile-content">

    {% for topic in topics.items %}

    <div class="panel page-panel">
        <div class="panel-heading page-head topic-head">
            <strong><a href="{{ topic.url }}">{{ topic.title }}</a></strong> in <a href="{{ topic.forum.url }}">{{ topic.forum.title }}</a>
        </div>

        <div class="panel-body page-body topic-content">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="topic-created">
                    {{ topic.date_created|format_date('%d %B %Y - %H:%M') }}
                </div>
                <div class="topic-content">
                {{ topic.first_post.content|markup|safe }}
                </div>
            </div>
        </div>
    </div>

    {% else %}
    <div class="row">
        <div class="col-md-12 col-sm-12 co-xs-12">
            <div class="alert-message alert-message-info" role="alert">
                {% trans %}The user has not opened any topics yet.{% endtrans %}
            </div>
        </div>
    </div> <!-- end forum-row -->
    {% endfor %}

    {% if topics.items|length > 1 %}
    <div class="col-md-12 col-sm-12 col-xs-12 controls-col">
        <div class="pull-left">
            {{ render_pagination(topics, url_for('user.view_all_topics', username=user.username)) }}
        </div>
    </div>
    {% endif %}

</div>
{% endblock %}
